package com.hk.admin.module.system.controller;

import com.hk.admin.common.base.controller.BaseController;
import com.hk.admin.common.base.dto.message.Message;
import com.hk.admin.module.system.service.LoginService;
import com.hk.admin.spring.security.UserDetail;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.security.Principal;

/**
 * <br>
 * <b>功能：</b>登录、登出<br>
 * <b>作者：</b>Pan.ShiJu<br>
 * <b>日期：</b>2017/4/11 23:27<br>
 */
@RestController
@RequestMapping("/system")
public class LoginController extends BaseController {

    @Autowired
    private LoginService loginService;

    /**
     * 登录
     * 1
     * $2a$10$Joh6UCftJL5rYwBxtd7qc.xu8ANntPrcHzp55NtWFWodFWAlOsi.G
     */
    @RequestMapping(value = "/login", method = RequestMethod.GET)
    public ResponseEntity<Message> login(Principal principal) {
        return loginService.login(principal.getName());
    }

    /**
     * 登出
     */
    @RequestMapping(value = "/logout", method = RequestMethod.GET)
    public ResponseEntity<Message> logout() {
        return success("退出成功");
    }


}
